<template>
    <!-- 侧边导航的选项卡 -->
    <div v-if="item.children">
        <el-menu-item v-if="item.children.length < 1" :index="item.url">
            <i :class="item.icon ? item.icon :'el-icon-menu'"></i>
            <span slot="title">{{item.name}}</span>
        </el-menu-item>
        <el-submenu v-else :index="item.url">
            <template slot="title">
                <i :class="item.icon ? item.icon :'el-icon-menu'"></i>
                <span>{{item.name}}</span>
            </template>
            <template v-for="child in item.children">
                <sidebar-item
                    v-if="child.children && child.children.length > 0"
                    :item="child"
                    :key="child.url"
                />
                <el-menu-item v-else :key="child.url" :index="child.url">
                    <i :class="child.icon ? child.icon :'el-icon-menu'"></i>
                    <span>{{child.name}}</span>
                </el-menu-item>
            </template>
        </el-submenu>
    </div>
</template>

<script>
export default {
    name: "SidebarItem",
    props: {
        item: {
            type: Object,
            required: true
        }
    }
};
</script>